package com.yxym.poly.polyparameter_;

public class TestEmployee {
    public static void main(String[] args) {
        Worker worker = new Worker("小明",15500.0);
        Manger manger = new Manger("小红",25500.0,100000.0);
        TestEmployee testEmployee = new TestEmployee();
        testEmployee.showEmpAnnual(worker);
        //worker.work();
        testEmployee.showEmpAnnual(manger);
        //manger.manage();
        testEmployee.testWork(manger);
        testEmployee.testWork(worker);
    }
    //动态绑定机制
    public void showEmpAnnual(Employee e){
        System.out.println(e.getAnnual());
    }
    public void testWork(Employee e){
        if (e instanceof Worker ){
            ((Worker) e).work();//向下转型
        }else if (e instanceof Manger){
            ((Manger) e).manage();//向下转型
        }else{
            System.out.println("输入的方法有误，请重新输入！");
        }
    }
}